<?php
class Wee_Logging_Block_Adminhtml_Details extends Mage_Adminhtml_Block_Widget_Container{
    protected $_currentEevent = null;
    protected $_eventUser = null;
    public function __construct(){
        parent :: __construct();
        $this -> _addButton('back', array('label' => Mage :: helper('wee_logging') -> __('Back'), 'onclick' => "setLocation('" . Mage :: getSingleton('adminhtml/url') -> getUrl('*/*/') . "')", 'class' => 'back'));
    }
    public function getHeaderText(){
        if ($this -> getCurrentEvent()){
            return Mage :: helper('wee_logging') -> __('Log Entry #%d', $this -> getCurrentEvent() -> getId());
        }
        return Mage :: helper('wee_logging') -> __('Log Entry Details');
    }
    public function getCurrentEvent(){
        if (null === $this -> _currentEevent){
            $this -> _currentEevent = Mage :: registry('current_event');
        }
        return $this -> _currentEevent;
    }
    public function getEventXForwardedIp(){
        if ($this -> getCurrentEvent()){
            $xForwarderFor = long2ip($this -> getCurrentEvent() -> getXForwardedIp());
            if ($xForwarderFor && $xForwarderFor != '0.0.0.0'){
                return $xForwarderFor;
            }
        }
        return false;
    }
    public function getEventIp(){
        if ($this -> getCurrentEvent()){
            return long2ip($this -> getCurrentEvent() -> getIp());
        }
        return false;
    }
    public function getEventError(){
        if ($this -> getCurrentEvent()){
            return nl2br($this -> getCurrentEvent() -> getErrorMessage());
        }
        return false;
    }
    public function getEventUser(){
        if(null === $this -> _eventUser){
            $this -> _eventUser = Mage :: getModel('admin/user') -> load($this -> getUserId());
        }
        return $this -> _eventUser;
    }
    public function getEventInfo(){
        $info = null;
        $data = $this -> getCurrentEvent() -> getInfo();
        try{
            $info = unserialize($data);
        }
        catch (Exception $e){
            $info = $data;
        }
        return $info;
    }
}
